package com.bbs.admin.user;

import com.bbs.utils.SystemResult;
import com.bbs.model.UserParams;
import com.bbs.user.User;
import com.bbs.user.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/api/user")
public class UserApiController {

    @Autowired
    UserService userService;

    @RequestMapping("/list")
    public SystemResult userList(@ModelAttribute UserParams userParams){
        return userService.userList(userParams);
    }

    @RequestMapping("/addOrUpdate")
    public SystemResult addOrUpdate(@ModelAttribute User user){
        return userService.addOrUpdate(user);
    }

    @RequestMapping("/del")
    public SystemResult del(Integer id){
        return userService.del(id);
    }

    @RequestMapping("/checkUser")
    public SystemResult checkUser(String userName){
        return userService.checkUser(userName);
    }
    @RequestMapping("/upload")
    public SystemResult upload(HttpServletRequest request){
        return userService.upload(request);
    }


}
